package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.account.Spipe;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.NightModeAsyncImageView;
import com.ss.android.common.util.NetworkStatusMonitor;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.image.model.ImageInfo;

public final class ax {
    boolean A;
    boolean B;
    long C;
    int D;
    final View.OnClickListener E;
    private ImageLoader F;
    private ImageLoader G;
    static int[] a;
    public View b;
    public TextView c;
    public ImageView d;
    public View e;
    public NightModeAsyncImageView f;
    public NightModeAsyncImageView g;
    public NightModeAsyncImageView h;
    public ViewGroup i;
    public NightModeAsyncImageView j;
    public NightModeAsyncImageView k;
    public DrawableButton l;
    public DrawableButton m;
    public TextView n;
    public TextView o;
    public ImageView p;
    public ImageView[] q;
    public Article r;
    public Context s;
    AppData t;
    public final Resources u;
    NetworkStatusMonitor v;
    int w;
    int x;
    public final int y;
    public final int z;

    static {
        ax.a = new int[]{17, 16, 18, 19};
    }

    public ax(Context arg2, NetworkStatusMonitor arg3, ImageLoader arg4, ImageLoader arg5, int arg6, int arg7, int arg8, int arg9) {

        this.A = false;
        this.B = false;
        this.E = new ay(this);
        this.s = arg2;
        this.v = arg3;
        Spipe.inst();
        this.t = AppData.getInstance();
        this.u = arg2.getResources();
        this.y = arg6;
        this.z = arg7;
        this.x = arg8;
        this.w = arg9;
        this.F = arg4;
        this.G = arg5;
    }

    static void a(ImageView arg1, int arg2, int arg3) {
        ViewGroup.LayoutParams v0 = arg1.getLayoutParams();
        if (v0 != null) {
            if (arg2 > 0) {
                v0.width = arg2;
            }

            if (arg3 > 0) {
                v0.height = arg3;
            }

            arg1.setLayoutParams(v0);
        }
    }

    static void a(NightModeAsyncImageView arg2, ImageInfo arg3) {
        android.support.design.a.setImage(((AsyncImageView) arg2), arg3);
        if (arg3 == null || arg3.mKey == null) {
            arg2.setTag(null);
            UIUtils.setVisibility(((View) arg2), 4);
        } else {
            UIUtils.setVisibility(((View) arg2), 0);
            arg2.setEnabled(true);
            arg2.setTag(com.ss.android.article.browser.R.id.image_info, arg3);
            Drawable v0 = arg2.getBackground();
            if (v0 != null) {
                v0.setLevel(0);
            }
        }
    }

    final void a() {
        Object v6 = null;
        int v5 = R.id.image_info;
        ImageInfo v0 = ax.a(this.j);
        if (v0 != null && this.G != null) {
            this.G.loadImage(this.j, v0, false);
        }

        if (this.F != null && this.e.getVisibility() == View.VISIBLE && this.q != null) {
            int v0_1;
            for (v0_1 = 0; v0_1 < 3; ++v0_1) {
                ImageInfo v2 = ax.a(this.q[v0_1]);
                if (v2 != null) {
                    this.F.loadImage(this.q[v0_1], v2, false);
                }
            }
        }

        if (this.F != null) {
            v0 = ax.a(this.k);
            if (v0 != null) {
                this.F.loadImage(this.k, v0, false);
            }
        }

        this.f.setTag(v5, v6);
        this.g.setTag(v5, v6);
        this.h.setTag(v5, v6);
        this.k.setTag(v5, v6);
        this.j.setTag(v5, v6);
    }

    private static ImageInfo a(ImageView arg3) {
        if (arg3 == null || arg3.getVisibility() != View.VISIBLE) {
            return null;
        } else {
            Object v0 = arg3.getTag(com.ss.android.article.browser.R.id.image_info);
            if ((v0 instanceof ImageInfo)) {
                return (ImageInfo) v0;
            } else {
                return null;
            }
        }

    }
}

